<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新员工信息录入')"/>
    <th:block th:include="include :: datetimepicker-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-roster-add" >
        <div class="form-group">
            <label class="col-sm-3 control-label">姓名
                ：</label>
            <div class="col-sm-8">
                <input name="fullName" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">手机
                ：</label>
            <div class="col-sm-8">
                <input name="mobilePhone" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">邮箱
                ：</label>
            <div class="col-sm-8">
                <input name="mailbox" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">性别
                ：</label>
            <div class="col-sm-8">
                <div class="radio-box" th:each="dict : ${@dict.getType('rnx_sys_gender')}">
                    <input type="radio" th:id="${dict.dictCode}" name="gender" th:value="${dict.dictValue}" th:checked="${dict.default}">
                    <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">年龄
                ：</label>
            <div class="col-sm-8">
                <input name="age" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">身份证号
                ：</label>
            <div class="col-sm-8">
                <input name="idNumber" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">证件有效期
                ：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <input name="certificateValidity" class="form-control" placeholder="格式：2022-01-01"
                           type="text">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">出生年月
                ：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <input name="dateOfBirth" class="form-control" placeholder="格式：2022-01-01"
                           type="text">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">婚姻
                ：</label>
            <div class="col-sm-8">
                <div class="radio-box" th:each="dict : ${@dict.getType('rnx_sys_marriage')}">
                    <input type="radio" th:id="${dict.dictCode}" name="marriage" th:value="${dict.dictValue}" th:checked="${dict.default}">
                    <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">民族
                ：</label>
            <div class="col-sm-8">
                <input name="nation" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">入职时间
                ：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <input name="entryDate" class="form-control" placeholder="格式：2022-01-01"
                           type="text">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">学历
                ：</label>
            <div class="col-sm-8">
                <div class="radio-box" th:each="dict : ${@dict.getType('rnx_sys_education')}">
                    <input type="radio" th:id="${dict.dictCode}" name="education" th:value="${dict.dictValue}" th:checked="${dict.default}">
                    <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">毕业院校
                ：</label>
            <div class="col-sm-8">
                <input name="universityOneIsGraduatedFrom" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">专业
                ：</label>
            <div class="col-sm-8">
                <input name="major" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">毕业时间
                ：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <input name="graduationTime" class="form-control" placeholder="格式：2022-01-01"
                           type="text">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">政治面貌
                ：</label>
            <div class="col-sm-8">
                <div class="radio-box" th:each="dict : ${@dict.getType('rnx_sys_political_outlook')}">
                    <input type="radio" th:id="${dict.dictCode}" name="politicalOutlook" th:value="${dict.dictValue}" th:checked="${dict.default}">
                    <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">首次参加工作时间
                ：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <input name="firstWorkingTime" class="form-control" placeholder="格式：2022-01-01"
                           type="text">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">籍贯
                ：</label>
            <div class="col-sm-8">
                <input name="nativePlace" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">户口性质
                ：</label>
            <div class="col-sm-8">
                <div class="radio-box" th:each="dict : ${@dict.getType('rnx_sys_nature_of_household_registration')}">
                    <input type="radio" th:id="${dict.dictCode}" name="natureOfHouseholdRegistration" th:value="${dict.dictValue}" th:checked="${dict.default}">
                    <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">户口所在地
                ：</label>
            <div class="col-sm-8">
                <textarea name="registeredResidence" class="form-control"></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">现住址
                ：</label>
            <div class="col-sm-8">
                <textarea name="currentAddress" class="form-control"></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">紧急联系人
                ：</label>
            <div class="col-sm-8">
                <input name="emergencyContactName" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">与本人关系
                ：</label>
            <div class="col-sm-8">
                <input name="relationshipWithMyself" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">紧急联系人电话
                ：</label>
            <div class="col-sm-8">
                <input name="emergencyContactNumber" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">银行
                ：</label>
            <div class="col-sm-8">
                <textarea name="bank" class="form-control"></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">开户行
                ：</label>
            <div class="col-sm-8">
                <textarea name="bankOfDeposit" class="form-control"></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">银行卡号
                ：</label>
            <div class="col-sm-8">
                <input name="bankCardNumber" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">备注
                ：</label>
            <div class="col-sm-8">
                <textarea name="remarks" class="form-control"></textarea>
            </div>
        </div>
    </form>
    <div class="btn-group-sm" id="toolbar" role="group">
        <a class="btn btn-success" onclick="save()">
            <i class="fa fa-save"></i> 保存
        </a>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<script th:inline="javascript">
    var prefix = ctx + "rnx/register"
    $("#form-roster-add").validate({
        focusCleanup: true,
        rules: {
            fullName : {
                required: true
            },
            mobilePhone: {
                required: true,
                isPhone: true
            },
            mailbox : {
                required: true,
                email: true
            },
            gender : {
                required: true
            },
            age : {
                required: true
            },
            idNumber : {
                required: true
            },
            registeredResidence : {
                required: true
            },
            currentAddress : {
                required: true
            },
            emergencyContactName : {
                required: true
            },
            emergencyContactNumber : {
                required: true
            },
            dateOfBirth : {
                required: true,
                date: true
            },
            marriage : {
                required: true
            },
            entryDate : {
                required: true,
                date: true
            },
            certificateValidity : {
                date: true
            },
            firstWorkingTime : {
                date: true
            },
            graduationTime : {
                date: true
            },
            education : {
                required: true
            },
            major : {
                required: true
            },
            universityOneIsGraduatedFrom : {
                required: true
            }
        },
        message: {
            fullName: {
                required: '姓名不能为空!'
            }
        },
       /* showErrors: function (errorMap, errorList) {
            //错误提示
            //$.modal.alertError(errorList[0].message);
            console.log(errorMap);
            console.log(errorList);
        }*/
    });

    //保存
    function save() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/update", $('#form-roster-add').serialize(),(r) => {
                if(r.code == 0){
                    $.modal.msgSuccess('提交成功!');
                    setTimeout(
                        () => {
                            window.location.href = prefix;
                        },3000
                    );
                }else{
                    $.modal.alertError(r.message);
                }
            });
        }
    }

    $("input[name='dateOfBirth']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $("input[name='entryDate']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $("input[name='graduationTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $("input[name='certificateValidity']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $("input[name='firstWorkingTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });
</script>
</body>
</html>